<?php
	include_once '../service/Gallery_Service.php';
        include_once '../service/Project_Service.php';
        include_once 'upload-file.php';


        $upload = new upload();

	$service_Gallery = new Gallery_Service();
        $service_Project = new Project_Service();

	$Action=$_GET['action'];
	//if (isset($_SESSION['login']) && $_SESSION['login'] == 1) {
	if($Action=='insert')
	{
               $result = $upload->upload_img($_FILES);
               $image_name = $_FILES['image']['name'];
                if($result ==''){
                    $pro_id = $_GET['id'];
                    $descript =$service_Project->getProject_Descript($pro_id);
                    $service_Gallery->insert_Gallery($image_name,$descript,$pro_id);
                    echo "<script>window.location='../admin/index.php'</script>";
                }
                else{
                    echo "<script>alert(".$result.")</script>";
                    echo "<script>window.location='../admin/index.php'</script>";
                }
	}
	
	if($Action=='delete')
	{
                $id =   $_GET['id'];
                $service_Gallery->delete_Gallery($id);
                echo "<script>window.location='../admin/index.php?action=mg&pro_id=".$_GET['pro_id']."'</script>";
	}
	//}
?>